package register;


import com.alibaba.nacos.api.exception.NacosException;
import enumeration.RpcError;
import exception.RpcException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import util.NacosUtil;

import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/*
* 服务注册
* */
public class NacosServiceRegistry implements ServiceRegister{

    private static final Logger logger = LoggerFactory.getLogger(NacosServiceRegistry.class);

    @Override
    public void registerService(String service, InetSocketAddress address) {
        try {
            NacosUtil.registerService(service, address);
        } catch (NacosException e) {
            logger.error("注册服务时有错误发生",e);
            throw new RpcException(RpcError.FAIL_TO_REGISTER_SERVICE);
        }
    }
}
